import { ElLoading, ElMessage, messageType } from "element-plus";

// 提示文本消息（默认效果）
export const showMessage = (
  str: string,
  type: messageType = "success",
  duration: number = 2500
) => {
  ElMessage({
    message: str,
    type,
    duration,
  });
};

let loading;

export const showLoading = (loadingText: string = "请求中") => {
  loading = ElLoading.service({
    lock: true,
    text: loadingText,
    background: "rgba(0, 0, 0, 0.7)",
  });
};

export const hideLoading = () => {
  loading.close();
};
